﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
namespace DAO
{
    public class PhanCongXeTaiXeDao
    {
        public int LayMa()
        {
            DoixeDataContext DX = new DoixeDataContext();

            int Lable;
            Lable = 0;
            int MA = 0;
            while (Lable == 0)
            {
                IEnumerable<PHANCONG_XE_TAIXE> pcDto;
                pcDto = from pc in DX.PHANCONG_XE_TAIXEs where pc.MaPCong == MA select pc;
                if (pcDto.Count() != 0)
                {
                    MA++;
                }
                else
                {
                    Lable = 1;
                }
            }
            return MA;
        }
        public void TiepNhanPhanCong(PHANCONG_XE_TAIXE P)
        {
            DoixeDataContext DX = new DoixeDataContext();
            DX.PHANCONG_XE_TAIXEs.InsertOnSubmit(P);
            DX.SubmitChanges();
        }
        public IEnumerable<PHANCONG_XE_TAIXE> BangPhanCong()
        {
            DoixeDataContext DX = new DoixeDataContext();
            return DX.PHANCONG_XE_TAIXEs;
        }
    }
}
